package com.stx.chat.controller;

import com.stx.chat.entity.Chat;
import com.stx.chat.entity.Message;
import com.stx.chat.entity.User;
import com.stx.chat.service.ChatService;
import com.stx.chat.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class ChatController {

    @Autowired
    ChatService chatService;
    @Autowired
    MessageService messageService;

    @RequestMapping("/chatinfo")
    public Map<String,Object> getChatinfo(){


        Map<String,Object> result = new HashMap<>();

        //获取聊天室信息
        Chat chat = chatService.selectOneChat();
        result.put("chat",chat);

        //获取成员列表信息
        List<User> memberList = chatService.memberList(chat.getId());
        result.put("memberList",memberList);

        //获取聊天记录的信息
        List<Message> messageList = messageService.messageList();
        result.put("messageList",messageList);

        return result;

    }



}
